#region Header
//=============================================================================
//                          GShield (Game Shield)
//=============================================================================
//
// Original Programmer: Shawn Jackson
// Company: WaveTech Digital Technologies, Inc. (http://www.wtdt.com)
// Copyright: (c) 2006 WaveTech Digital Technologies, Inc. All Rights Reserved.
// Assembly: Library
// Code File Name: UsagePolicy.cs
// Code File Date: 10/22/2006
//
// Code File Info: Usage Policy Object Definiation
//=============================================================================
/*
 * UPDATES
 * -------
 *			ShawnJ 5/4/2007 (0.9.0.x): Refactoring for OSS.
 *			ShawnJ 8/7/2007 (0.9.5.x): Code Commenting.
 */
#endregion Header

#region License
/*
  GShield - Game Shield
  Copyright (C) 2006-2007 WaveTech Digital Technologies, Inc.
                                http://www.wtdt.com

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/
#endregion License

#region Includes
using System;
using System.Globalization;
using System.Text;
using WaveTech.GShield.Library.Enumerations;
#endregion Includes

namespace WaveTech.GShield.Library.Objects
{
    /*
  /// <summary>
  /// Class defining a UsagePolicy object
  /// </summary>
	[Serializable]
  public class UsagePolicy
	{
		#region Private Members
		private int? m_id;
		private string m_userName;
		private DateTime? m_startDate;
		private DateTime? m_endDate;
		private int? m_monday;
		private TimeType? m_mondayType;
		private int? m_tuesday;
		private TimeType? m_tuesdayType;
		private int? m_wednesday;
		private TimeType? m_wednesdayType;
		private int? m_thursday;
		private TimeType? m_thursdayType;
		private int? m_friday;
		private TimeType? m_fridayType;
		private int? m_saturday;
		private TimeType? m_saturdayType;
		private int? m_sunday;
		private TimeType? m_sundayType;
		private DateTime? m_timestamp;
		private string m_hash;
		#endregion Private Members

		#region Public Properties
		/// <summary>
		/// Primary Identifier for this object
		/// </summary>
		public int? Id
    {
      get { return m_id; }
      set { m_id = value; }
    }

		/// <summary>
		/// Username of the user the policy if for
		/// </summary>
    public string UserName
    {
      get { return m_userName; }
      set { m_userName = value; }
    }

		/// <summary>
		/// Start date of the policy (Outside Effective Range)
		/// </summary>
    public DateTime? StartDate
    {
      get { return m_startDate; }
      set { m_startDate = value; }
    }

		/// <summary>
		/// End date of the policy (Outside Effective Range)
		/// </summary>
    public DateTime? EndDate
    {
      get { return m_endDate; }
      set { m_endDate = value; }
    }

		/// <summary>
		/// Total allowed playing time for Monday
		/// </summary>
    public int? Monday
    {
      get { return m_monday; }
      set { m_monday = value; }
    }

		/// <summary>
		/// Allowed playing time for Mondays time type (Minutes/Hours)
		/// </summary>
    public TimeType? MondayType
    {
      get { return m_mondayType; }
      set { m_mondayType = value; }
    }

		/// <summary>
		/// Total allowed playing time for Tuesdays
		/// </summary>
    public int? Tuesday
    {
      get { return m_tuesday; }
      set { m_tuesday = value; }
    }

		/// <summary>
		/// Allowed playing time for Tuesday time type (Minutes/Hours)
		/// </summary>
    public TimeType? TuesdayType
    {
      get { return m_tuesdayType; }
      set { m_tuesdayType = value; }
    }

		/// <summary>
		/// Total allowed playing time for Wednesdays
		/// </summary>
    public int? Wednesday
    {
      get { return m_wednesday; }
      set { m_wednesday = value; }
    }

		/// <summary>
		/// Allowed playing time for Wednesday time type (Minutes/Hours)
		/// </summary>
    public TimeType? WednesdayType
    {
      get { return m_wednesdayType; }
      set { m_wednesdayType = value; }
    }

		/// <summary>
		/// Total allowed playing time for Thursdays
		/// </summary>
    public int? Thursday
    {
      get { return m_thursday; }
      set { m_thursday = value; }
    }

		/// <summary>
		/// Allowed playing time for Thursday time type (Minutes/Hours)
		/// </summary>
    public TimeType? ThursdayType
    {
      get { return m_thursdayType; }
      set { m_thursdayType = value; }
    }

		/// <summary>
		/// Total allowed playing time for Fridays
		/// </summary>
    public int? Friday
    {
      get { return m_friday; }
      set { m_friday = value; }
    }

		/// <summary>
		/// Allowed playing time for Friday time type (Minutes/Hours)
		/// </summary>
    public TimeType? FridayType
    {
      get { return m_fridayType; }
      set { m_fridayType = value; }
    }

		/// <summary>
		/// Total allowed playing time for Saturdays
		/// </summary>
    public int? Saturday
    {
      get { return m_saturday; }
      set { m_saturday = value; }
    }

		/// <summary>
		/// Allowed playing time for Saturday time type (Minutes/Hours)
		/// </summary>
    public TimeType? SaturdayType
    {
      get { return m_saturdayType; }
      set { m_saturdayType = value; }
    }

		/// <summary>
		/// Total allowed playing time for Sundays
		/// </summary>
    public int? Sunday
    {
      get { return m_sunday; }
      set { m_sunday = value; }
    }

		/// <summary>
		/// Allowed playing time for Sunday time type (Minutes/Hours)
		/// </summary>
    public TimeType? SundayType
    {
      get { return m_sundayType; }
      set { m_sundayType = value; }
    }

		/// <summary>
		/// Usage policy record time stamp
		/// </summary>
    public DateTime? Timestamp
    {
      get { return m_timestamp; }
      set { m_timestamp = value; }
    }

		/// <summary>
		/// Stored hash for this object
		/// </summary>
    public string Hash
    {
      get { return m_hash; }
      set { m_hash = value; }
    }

    #endregion Public Properties

    #region Get Allowed Playing Time
		/// <summary>
		/// Gets the total allows playing time in minutes for
		/// a given day.
		/// </summary>
		/// <param name="day">Day of the week to get time for</param>
		/// <returns>Nullable integer, null if no playing time, else a value int minutes.</returns>
    public int? GetAllowedPlayingTime(DayOfWeek day)
    {
      if (day == DayOfWeek.Monday)
      {
        if (m_monday.HasValue)
          if (m_mondayType == TimeType.Hours)
            return m_monday.Value * 60;
          else
            return m_monday.Value;
      }
      else if (day == DayOfWeek.Tuesday)
      {
        if (m_tuesday.HasValue)
          if (m_tuesdayType == TimeType.Hours)
            return m_tuesday * 60;
          else
            return m_tuesday;
      }
      else if (day == DayOfWeek.Wednesday)
      {
        if (m_wednesday.HasValue)
          if (m_wednesdayType == TimeType.Hours)
            return m_wednesday * 60;
          else
            return m_wednesday;
      }
      else if (day == DayOfWeek.Thursday)
      {
        if (m_thursday.HasValue)
          if (m_thursdayType == TimeType.Hours)
            return m_thursday * 60;
          else
            return m_thursday;
      }
      else if (day == DayOfWeek.Friday)
      {
        if (m_friday.HasValue)
          if (m_fridayType == TimeType.Hours)
            return m_friday * 60;
          else
            return m_friday;
      }
      else if (day == DayOfWeek.Saturday)
      {
        if (m_saturday.HasValue)
          if (m_saturdayType == TimeType.Hours)
            return m_saturday * 60;
          else
            return m_saturday;
      }
      else if (day == DayOfWeek.Sunday)
      {
        if (m_sunday.HasValue)
          if (m_sundayType == TimeType.Hours)
            return m_sunday * 60;
          else
            return m_sunday;
      }

      return null;
    }
    #endregion Get Allowed Playing Time

    #region Compute Hash
		/// <summary>
		/// Computes the current hash for critical object members
		/// </summary>
		/// <returns>Hash as a string</returns>
    public string ComputeHash()
    {
      StringBuilder newHash = new StringBuilder();

			if (m_userName != null)
				newHash.Append(m_userName);
      
      if (m_monday.HasValue)
				newHash.Append(m_monday.Value.ToString(CultureInfo.InvariantCulture));

      if (m_tuesday.HasValue)
				newHash.Append(m_tuesday.Value.ToString(CultureInfo.InvariantCulture));

      if (m_wednesday.HasValue)
				newHash.Append(m_wednesday.Value.ToString(CultureInfo.InvariantCulture));

      if (m_thursday.HasValue)
				newHash.Append(m_thursday.Value.ToString(CultureInfo.InvariantCulture));

      if (m_friday.HasValue)
				newHash.Append(m_friday.Value.ToString(CultureInfo.InvariantCulture));

      if (m_saturday.HasValue)
				newHash.Append(m_saturday.Value.ToString(CultureInfo.InvariantCulture));

      if (m_sunday.HasValue)
				newHash.Append(m_sunday.Value.ToString(CultureInfo.InvariantCulture));

			return Common.Hash.ComputeHash(newHash.ToString(), "SHA256", null);
    }
    #endregion Compute Hash

    #region Is Hash Valid
		/// <summary>
		/// Checks to ensure the computed hash matches the current
		/// hash of critical object members.
		/// </summary>
		/// <returns>True if the hashs match, otherwise false.</returns>
    public bool IsHashValid()
    {
			if (m_hash == null)
				return false;

			return Common.Hash.VerifyHash(ComputeHash(), "SHA256", m_hash);
    }
    #endregion Is Hash Valid
  }
    */
}